package com.totoro.project.spboot_rabbitMQ_server;

import com.totoro.project.spboot_rabbitMQ_server.config.MQConfig;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * Created by Administrator on 2017/9/11.
 */
@RestController
public class SenderController {

    @Resource
    SendService sendService ;

    @GetMapping("/send/{queue}/{msg}")
    public String sendMessage(@PathVariable String queue, @PathVariable  String msg){
        sendService.send(queue, msg);
        return "success" ;
    }

    @GetMapping("/send-default/{msg}")
    public String sendDefaultMessage(@PathVariable String msg){
        sendService.send(MQConfig.EXCHANGE, MQConfig.ROUTINGKEY,msg);
        return "successs" ;
    }

    @GetMapping("/send/{exchange}/{routingKey}/{msg}")
    public String sendMessage(@PathVariable String exchange, @PathVariable String routingKey, @PathVariable String msg){
        sendService.send(exchange, routingKey, msg);
        return "success" ;
    }


    @GetMapping("/send/fanout/{exchange}/{msg}")
    public String sendFanoutMessage(@PathVariable String exchange, @PathVariable String msg){
        sendService.send(exchange,null, msg);
        return "success" ;
    }


}
